package hng.mapper;

import hng.model.CartDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import hng.vo.CartProductVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 购物车表 Mapper 接口
 * </p>
 *
 * @author 告白
 * @since 2024-06-27
 */
public interface CartMapper extends BaseMapper<CartDO> {

    /**
     * 查询购物车商品列表
     */
    @Select("select c.*, s.name as spec_name, s.price, p.name , p.cover_url, p.store_id " +
            "from cart c " +
            "left join product p on c.product_id = p.id " +
            "left join product_spec s on c.spec_id = s.id " +
            "where c.user_id = #{userId} " +
            "order by c.create_time desc ") 


    List<CartProductVO> getList(@Param("userId") Integer userId);
}
